﻿<%@ Page Language="C#" MasterPageFile="~/SiteLayout.Master" AutoEventWireup="true" CodeBehind="AddTreeLocations.aspx.cs" Inherits="ForestryEnterprise.AddTreeLocations" %>
<asp:Content ID="Content2" ContentPlaceHolderID="context" runat="server">
    <h2>Add Tree Locations</h2>
    <hr />
    <label>Pick tree:</label>
    <asp:DropDownList ID="trees" runat="server" 
        onselectedindexchanged="trees_SelectedIndexChanged" AutoPostBack="true" />
    <label style="margin-left:50px;">Pick existing location:</label>
    <asp:DropDownList ID="locations" runat="server" AutoPostBack="true" 
        onselectedindexchanged="locations_SelectedIndexChanged"/>
    <br />
    <label>Location name:</label>
    <asp:TextBox id="locName" runat="server" />
    <br />
    <label>Location country:</label>
    <asp:TextBox id="locCountry" runat="server" />
    <asp:RequiredFieldValidator ID="reqCountry" ControlToValidate="locCountry" ErrorMessage="Must provide country" runat="server" />
    <br />
    <label>Location area:</label>
    <asp:TextBox id="locArea" runat="server" />
    <asp:RequiredFieldValidator ID="reqArea" ControlToValidate="locArea" ErrorMessage="Must provide area" runat="server" />
    <br />
    <label>Location altitude:</label>
    <asp:TextBox id="locAltitude" runat="server" />
    <asp:RequiredFieldValidator ID="reqAltitude" ControlToValidate="locAltitude" ErrorMessage="Must input Altitude " runat="server" Display="Dynamic"/>
    <asp:RegularExpressionValidator ID="regAlt" ControlToValidate="locAltitude" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Number (float point)" runat="server" Display="Dynamic"/>
    <br />
    <label>Location latitude:</label>
    <asp:TextBox id="locLatitude" runat="server" />
    <asp:RequiredFieldValidator ID="reqLatitude" ControlToValidate="locLatitude" ErrorMessage="Must input Latitude " runat="server" Display="Dynamic"/>
    <asp:RegularExpressionValidator ID="regLat" ControlToValidate="locLatitude" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Number (float point)" runat="server" Display="Dynamic"/>
    <br />
    <label>Location longitude:</label>
    <asp:TextBox id="locLongitude" runat="server" />
    <asp:RequiredFieldValidator ID="reqLong" ControlToValidate="locLongitude" ErrorMessage="Must input Longitude " runat="server" Display="Dynamic"/>
    <asp:RegularExpressionValidator ID="regLong" ControlToValidate="locLongitude" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Number (float point)" runat="server" Display="Dynamic"/>
    <br />
    <asp:Button ID="addNewLoc" Text="Add New" runat="server" 
        onclick="addNewLoc_Click" />
    <asp:Button ID="updateLoc" Text="Update" runat="server" Enabled="false" 
        onclick="updateLoc_Click" />
    <hr />
    <asp:GridView ID="treeLocations" runat="server" AutoGenerateColumns="false" DataSourceID="treeLocationsDB" DataKeyNames="l_id" Width="100%">
        <AlternatingRowStyle BackColor="#F0F0F0"/>

        <Columns>
            <asp:BoundField DataField="l_name" HeaderText="Location" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="l_country" HeaderText="Country" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="l_area" HeaderText="Area" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="l_altitude" HeaderText="Altitude" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="l_latitude" HeaderText="Latitude" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="l_longitude" HeaderText="Longitude" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
        </Columns> 
    </asp:GridView>
    <asp:AccessDataSource ID="treeLocationsDB" DataFile="~/App_Data/ForestryEnterprise.mdb" runat="server"/>
    <asp:Label ID="err" runat="server" style="color:Red;"/>
</asp:Content>